package com.factors.ZhangDingHou.Distance_from_Home;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class DistanceFromHomeCountMapper extends Mapper<LongWritable, Text, Text, DistanceFromHomeCount> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] columns = value.toString().split(",");
        if (columns.length >= 20) {
            try {
                String distanceFromHome = columns[17];


                context.write(new Text(distanceFromHome), new DistanceFromHomeCount(1));
            } catch (Exception e) {

            }
        }
    }
}